﻿
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using Model;


namespace MsDAL
{
    public partial class Sto7a00DAL : Sto7a00Base
    {
        /// <summary>
        /// 更新订单状态为已打印配货单
        /// </summary>
        public SqlApp AlreadyReciveDoc(string listid)
        {
            string sql = "UPDATE Sto7a00 SET status = '10' WHERE tranid = @tranid AND status = '4' ";
            SqlParameter[] parameters = {
				new SqlParameter("@tranid", SqlDbType.NVarChar)
				};
            parameters[0].Value = listid;

            return new SqlApp(sql, new ArrayList(parameters), false, " 更新收货状态失败！");
        }

        /// <summary>
        /// 更新打印配货单状态出错
        /// </summary>
        public SqlApp AlreadyPrePintDoc(string listid)
        {
            string sql = "UPDATE Sto7a00 SET status = '11' WHERE tranid = @tranid AND status = '1' ";
            SqlParameter[] parameters = {
				new SqlParameter("@tranid", SqlDbType.NVarChar)
				};
            parameters[0].Value = listid;

            return new SqlApp(sql, new ArrayList(parameters), false, " 更新打印配货单状态出错！");
        }

        /// <summary>
        /// 调拨接收
        /// </summary>
        /// <param name="listid"></param>
        /// <returns></returns>
        public SqlApp AlreadySendDoc(string listid)
        {
            string sql = "UPDATE Sto7a00 SET status = '4' WHERE tranid = @tranid AND status IN('1','11') ";
            SqlParameter[] parameters = {
				new SqlParameter("@tranid", SqlDbType.NVarChar)
				};
            parameters[0].Value = listid;

            return new SqlApp(sql, new ArrayList(parameters), false, " 更新发货状态失败！");
        }

        /// <summary>
        /// 发货
        /// <param name="listid">订单标识主键</param>
        /// <param name="pqty">配送数量</param>
        /// </summary>
        public SqlApp Send(string listid, double pqty)
        {
            string sql = string.Format("stosend_sp '{0}','{1}' ",
                    listid, pqty);

            return new SqlApp(sql, null, false, "");
        }

        public SqlApp Recive(string listid, double pqty)
        {
            string sql = string.Format("storecive_sp '{0}','{1}' ",
                    listid, pqty);

            return new SqlApp(sql, null, false, "");
        }

        public SqlApp Adjuest(string listid, double pqty)
        {
            string sql = string.Format("stoadjuest_sp '{0}','{1}' ",
                    listid, pqty);

            return new SqlApp(sql, null, false, "");
        }
    }
}
